#!/usr/bin/env python
# -*- coding:utf-8 -*-
file1 = "/root/a.txt"
file2 = "/root/b.txt"
f_diff = "/root/c.txt"
f1 = open(file1,"r")
f2 = open(file2,"r")
file1 = f1.readlines()
file2 = f2.readlines()
f1.close
f2.close
outfile = open(f_diff,"w")
flag = 0
outfile.write("file1独有的数据: \n")
for i in file1:
        if i not in file2:
                outfile.write(i)
                flag = 1
outfile.write("file2独有的数据: \n")
for i in file2:
        if i not in file1:
                outfile.write(i)
                flag = 1
outfile.close()
if flag == 1:
        print "数据存在差异，请仔细核对"